Skip to content

[_operator] Type add and sub mimicking mul in #15598. #15601

Merged
srittau merged 3 commits intopython:mainfrom
hunterhogan:operator.add_sub
Apr 5, 2026
Merged

[_operator] Type add and sub mimicking mul in #15598. #15601
srittau merged 3 commits intopython:mainfrom
hunterhogan:operator.add_sub

Conversation

@hunterhogan
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

This comment has been minimized.

@srittau
Copy link
Copy Markdown
Collaborator

srittau commented Apr 5, 2026

The primer hits seem similar to those #15598. I.e. mypy bugs or inability to derive a common base type due to now missing Any inference. The rotkehlchen hit is a true positive (from a type checking perspective, although it will work at runtime).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

colour (https://github.com/colour-science/colour)
+ colour/utilities/array.py:547: error: Cannot call function of unknown type  [operator]
+ colour/io/luts/lut.py:638: error: Cannot call function of unknown type  [operator]
+ colour/continuous/signal.py:1089: error: Cannot call function of unknown type  [operator]

spark (https://github.com/apache/spark)
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[float | Literal[0], float | Literal[0]], float | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[complex | Literal[0], complex | Literal[0]], complex | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[signedinteger[_32Bit] | Literal[0], signedinteger[_32Bit] | Literal[0]], signedinteger[_32Bit] | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[signedinteger[_64Bit] | Literal[0], signedinteger[_64Bit] | Literal[0]], signedinteger[_64Bit] | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[floating[_32Bit] | Literal[0], floating[_32Bit] | Literal[0]], floating[_32Bit] | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[float64 | Literal[0], float64 | Literal[0]], float64 | Literal[0]]"  [arg-type]
+ python/pyspark/core/rdd.py:2155: error: Argument 2 to "fold" of "RDD" has incompatible type overloaded function; expected "Callable[[ndarray[tuple[Any, ...], dtype[Any]] | Literal[0], ndarray[tuple[Any, ...], dtype[Any]] | Literal[0]], ndarray[tuple[Any, ...], dtype[Any]] | Literal[0]]"  [arg-type]

rotki (https://github.com/rotki/rotki)
+ rotkehlchen/utils/misc.py:199: error: Argument 1 to "sub" has incompatible type "V | Any"; expected "SupportsSub[Any, Any]"  [arg-type]
+ rotkehlchen/utils/misc.py:199: note: Error code "arg-type" not covered by "type: ignore" comment

@srittau srittau merged commit c6b7c0b into python:main Apr 5, 2026
51 checks passed
@hunterhogan hunterhogan deleted the operator.add_sub branch April 5, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants